package cn.house.dao;

import cn.house.pojo.Users;
import cn.house.util.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class UsersDao{

    public Session session=HibernateUtil.getSession();

    /**
     * 登录
     * @param
     * @return
     */
    public long Login(Users users){

        String hql="select count(*) from Users where name=:name and password=:password";
        Transaction ts=session.beginTransaction();
        Query query=session.createQuery(hql);
        query.setProperties(users);
        long count=(long)query.uniqueResult();
        ts.commit();
        return  count;

    }

}
